<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
      <el-form-item label="订单编号" prop="orderNo">
        <el-input v-model="queryParams.orderNo" placeholder="请输入订单编号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="服务技师" prop="jishiNickName">
        <el-input v-model="queryParams.jishiNickName" placeholder="请输入服务技师" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="用户昵称" prop="fromNicheng">
        <el-input v-model="queryParams.fromNicheng" placeholder="请输入用户昵称" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="评价时间" prop="createTime">
        <el-date-picker @change="createTimeChange" v-model="createTime" type="daterange" range-separator="至"
                start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
              </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="tabList" @selection-change="handleSelectionChange">
      
      <el-table-column label="订单编号" align="center" prop="orderNo" />
      <el-table-column label="服务技师" align="center" prop="jishiNickName" />
      <el-table-column label="用户姓名" align="center" prop="fromNicheng" />
      <el-table-column label="用户电话" align="center" prop="fromPhoneNumber" />
      <el-table-column label="评论星级" align="center" prop="startNum" />
      <el-table-column label="内容" align="center" prop="content" />
      <el-table-column label="评价时间" align="center" prop="createTime" />
      <el-table-column label="操作" align="center" prop="">
        <template slot-scope="scope">
          <div v-if="scope.row.commentStatus == 0" style="color:cornflowerblue;">
          <span @click="replyClick(scope.row.id)" style="margin-right:10px;cursor: pointer;" v-hasPermi="['admin:comment:remove']">删除</span>
          <span @click="applyClick(scope.row.id)" style="cursor: pointer;" v-hasPermi="['admin:comment:edit']">通过</span></div>
          <div v-else>已上架</div>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>
    
  <script>
  import { list,remove,pass} from "@/api/comment/comment";
  import { getToken } from '@/utils/auth'
  export default {
    name: "Knowledge",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 表格数据
        tabList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
        },
        createTime:null,
        id:'',
        pupopForm:{},
      };
    },
    created() {
      this.getList();
      //在字典查询-解决类型
    },
    methods: {
      /** 搜索按钮操作 */
      handleQuery() {

        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.createTimeStart = '' 
        this.createTimeEnd = ''
        this.handleQuery();
      },
      //评论时间
      createTimeChange() {
        this.createTimeStart = this.createTime[0] 
        this.createTimeEnd = this.createTime[1]
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        this.queryParams.createTimeStart = this.createTimeStart;
        this.queryParams.createTimeEnd = this.createTimeEnd;
        list(this.queryParams).then(response => {
          this.tabList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      //删除
      replyClick(id){
        const ids = id || this.ids;
        remove(ids).then(response => {
          if(response.code == "200"){
            this.$message({message: '删除成功',type: 'success'});
            this.getList()
          }
        });
      },
      applyClick(id){
        pass(id).then(response => {
          console.log(response.code)
          if(response.code == "200"){
            this.$message({message: '成功',type: 'success'});
            this.getList()
          }
        });
      }
    }
  };
  </script>
  <style>
  .popupCont{
      min-height: 80px;
      padding: 10px ;
      font-size: 14px;
      color:#333;
      border-radius: 6px;
      border:1px solid #999;
    }
    .quesEditBtn{
      text-align: center;
    }
  </style>
    